<?php
class Restaurant{
	
	public $id_restaurant;
	public $referent_restaurant;
	public $nom_restaurant;
	public $telephone_restaurant;
	public $description_restaurant;
	public $site_restaurant;
	public $horaire_restaurant;
	
	public function __construct($donnee){
		$this->hydrate($donnee);
		if(empty($this->telephone_restaurant)){
			$this->telephone_restaurant='';
		}
		if(empty($this->site_restaurant))
			$this->site_restaurant = "";
		if(empty($this->description_restaurant))
			$this->description_restaurant = "";
	}
	
	public function setId_restaurant($var){
		if(is_int($var))
			$this->id_restaurant = $var;
	}
	public function setReferent_restaurant($var){
		if(is_int($var))
			$this->referent_restaurant = $var;
	}
	public function setNom_restaurant($var){
		if(is_string($var))
			$this->nom_restaurant = $var;
	}
	public function setTelephone_restaurant($var){
		if(is_string($var))
			$this->telephone_restaurant = $var;
		 
	}
	public function setDescription_restaurant($var){
		if(is_string($var))
			$this->description_restaurant = $var;
	}
	public function setSite_restaurant($var){
		if(is_string($var))
			$this->site_restaurant = $var;
	}
	public function setHoraire_restaurant($var){
		if(is_array($var))
			$this->horaire_restaurant = $var;
	}
	
	public function hydrate(array $donnees1){
		
  		foreach ($donnees1 as $key => $value){
   		 // On récupère le nom du setter correspondant à l'attribut.
   		 $method = 'set'.ucfirst($key);
         
   		 // Si le setter correspondant existe.
    	if (method_exists($this, $method)){
     	 // On appelle le setter.
     	 $this->$method($value);
		}
  	}
	}

	
}